#include <string.h>

#include "lib.h"

#include "strftest.h"
#include "striter.h"
#include "opthelpr.h"
#include "pghand.h"
#include "jokcrdmg.h"

StraightFlushTest::StraightFlushTest(PGPokerHand* hand, uint8* suits)
{
	this->hand = hand;

	findMax(&flushSuit, suits, 4);
	flushSuit = NDXSUIT(flushSuit);
}

bool8
StraightFlushTest::hasStraightFlush(int32* start)
{
	int32 i;

	memset(counts, 0, 13 + 1);

	for (i = 0; i < hand->getCount(); i++)
	{
		if (!HPTR_ISJOKER_AT(i))
		{
			if (flushSuit == HPTR_GETSUIT_AT(i))
				++HAS(HPTR_GETRANK_AT(i));
		}
		else
			++HASJOKER();
	}

	StraightIter iter(counts);

	if (iter.findStraight(true, true))
	{
		*start = iter.getStartRank();

		return true;
	}

	return false;
}
